package com.hzit.service.impl;

import com.hzit.entity.Classes;
import com.hzit.mapper.ClassesMapper;
import com.hzit.service.IClassesService;
import com.hzit.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.io.IOException;
import java.util.List;

public class ClassessServiceImpl implements IClassesService {

	//1. 查询所有班级
	@Override
	public List<Classes> findAll() throws IOException {
		SqlSessionFactory sqlSessionFactory = MyBatisUtil.getSqlSessionFactory();
		try(SqlSession sqlSession = sqlSessionFactory.openSession(true)){
			ClassesMapper mapper = sqlSession.getMapper(ClassesMapper.class);
			return mapper.selectByExample(null);
		}
	}
}
